package org.zjt.serialize;

import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;
import lombok.Builder;
import lombok.Getter;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;

import java.io.Serializable;

/**
 * Description:
 *
 *          xml 利用XStream 序列化、反序列化
 *
 * @author juntao.zhang
 * Date: 2018-07-12 上午11:36
 * @see
 */
@Slf4j
public class XStreamTest {


    public static void main(String[] args) {
//        XStream xStream = new XStream(new DomDriver());
//        HessianOperationTest.Person zhangsan = HessianOperationTest.Person.builder().age(23).name("ZHANGSAN").build();
//        xStream.alias("person",HessianOperationTest.Person.class);
//
//        String xml = xStream.toXML(zhangsan);
//
//        log.info("序列化后的 xml:\n{}",xml);
//
//
//        HessianOperationTest.Person person = (HessianOperationTest.Person)xStream.fromXML(xml);
//
//        log.info("反序列化后的 person: {}",person);
    }

    @Builder
    @Getter
    @ToString
    public static class Person implements Serializable {

        private String name;
        private Integer age;

    }
}
